import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import 'nprogress/nprogress.css'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import { createApp } from 'vue'

import App from './App.vue'
import setupDirectives from './directives'
import router from './router/permission'

// 导入全局样式
import '@/assets/styles/global.scss'

const app = createApp(App)

// 配置 Pinia
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
app.use(pinia)

// 配置 Element Plus
app.use(ElementPlus, {
  locale: zhCn,
})

// 注册 Element Plus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 注册全局指令
setupDirectives(app)

// 配置路由
app.use(router)

// 挂载应用
app.mount('#app')

// 打印应用信息
console.log(
  '%c后台管理系统%c v1.0.0',
  'color: #409eff; font-size: 20px; font-weight: bold;',
  'color: #67c23a; font-size: 14px;'
)
console.log('%c构建时间:', 'color: #909399;', __BUILD_TIME__)
